/*
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 *
 * Copyright 2010 huliqing, huliqing.cn@gmail.com
 *
 * This file is part of QFaces.
 * QFaces is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * QFaces is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with QFaces.  If not, see <http://www.gnu.org/licenses/>.
 *
 * 这个文件是QFaces的一部分。
 * 您可以单独使用或分发这个文件，但请不要移除这个头部声明信息.
 * QFaces是一个自由软件，您可以自由分发、修改其中的源代码或者重新发布它，
 * 新的任何修改后的重新发布版必须同样在遵守LGPL3或更后续的版本协议下发布.
 * 关于LGPL协议的细则请参考COPYING、COPYING.LESSER文件，
 * 您可以在QFaces的相关目录中获得LGPL协议的副本，
 * 如果没有找到，请连接到 http://www.gnu.org/licenses/ 查看并获取副本。
 *
 * - Author: Huliqing
 * - Contact: huliqing.cn@gmail.com
 * - License: GNU Lesser General Public License (LGPL)
 * - Blog and source code availability: http://www.huliqing.name/
 */

Q.F.UIEditor = {
	initEditor : function(ID_CLIENT, ID_MIN_ZONE, ID_FULL_ZONE, ID_VIEW_ZONE, ID_INPUT, ID_IFRAME, ID_CONTENT, ID_MODE, ID_TOOLS, ID_TOOLS_EXT, ID_ZOOM_IN, ID_ZOOM_OUT, colorList) {
		var editor = new Q.F.UIEditor.Editor(ID_CLIENT, ID_MIN_ZONE, ID_FULL_ZONE, ID_VIEW_ZONE, ID_INPUT, ID_IFRAME, ID_CONTENT, ID_MODE, ID_TOOLS, ID_TOOLS_EXT, ID_ZOOM_IN, ID_ZOOM_OUT, colorList);
		Q.F.put(ID_CLIENT, editor);
	},
	getEditor : function(clientId) {
		return Q.F.find(clientId);
	},
	doBold : function(clientId) {
		this.getEditor(clientId).exec("Bold");
	},
	doItalic : function(clientId) {
		this.getEditor(clientId).exec("Italic");
	},
	doUnderline : function(clientId) {
		this.getEditor(clientId).exec("Underline");
	},
	doStrikeThrough : function(clientId) {
		this.getEditor(clientId).exec("StrikeThrough");
	},
	doSubscript : function(clientId) {
		this.getEditor(clientId).exec("Subscript");
	},
	doSuperscript : function(clientId) {
		this.getEditor(clientId).exec("Superscript");
	},
	doJustifyLeft : function(clientId) {
		this.getEditor(clientId).exec("JustifyLeft");
	},
	doJustifyCenter : function(clientId) {
		this.getEditor(clientId).exec("JustifyCenter");
	},
	doJustifyRight : function(clientId) {
		this.getEditor(clientId).exec("JustifyRight");
	},
	doJustifyFull : function(clientId) {
		this.getEditor(clientId).exec("JustifyFull");
	},
	doRemoveFormat : function(clientId) {
		this.getEditor(clientId).exec("RemoveFormat");
	},
	doUnlink : function(clientId) {
		this.getEditor(clientId).exec("Unlink");
	},
	doOutdent : function(clientId) {
		this.getEditor(clientId).exec("Outdent");
	},
	doIndent : function(clientId) {
		this.getEditor(clientId).exec("Indent");
	},
	doUndo : function(clientId) {
		this.getEditor(clientId).exec("Undo");
	},
	doRedo : function(clientId) {
		this.getEditor(clientId).exec("Redo");
	},
	doOrderList : function(clientId) {
		this.getEditor(clientId).exec("InsertOrderedList");
	},
	doUnOrderList : function(clientId) {
		this.getEditor(clientId).exec("InsertUnorderedList");
	},
	doFontName : function(clientId, selectObj) {
		this.getEditor(clientId).exec("FontName", selectObj.value);
	},
	doFontSize : function(clientId, selectObj) {
		this.getEditor(clientId).exec("FontSize", selectObj.value);
	},
	doCreateLink : function(clientId, target) {
		var _linkPanel = this.getEditor(clientId).getLinkPanel();
		_linkPanel.setVisible(!_linkPanel.isVisible());
		target.appendChild(_linkPanel.getPanel());
	},
	doForeColor : function(clientId, target) {
		var _colorPanel = this.getEditor(clientId).getColorPanel();
		_colorPanel.setTask("ForeColor");
		target.appendChild(_colorPanel.getPanel());
	},
	doBackColor : function(clientId, target) {
		var _colorPanel = this.getEditor(clientId).getColorPanel();
		_colorPanel.setTask("BackColor");
		target.appendChild(_colorPanel.getPanel());
	},
	doInsertImage : function(clientId, target) {
		var _imagePanel = this.getEditor(clientId).getImagePanel();
		_imagePanel.setVisible(!_imagePanel.isVisible());
		target.appendChild(_imagePanel.getPanel());
	},
	doInsertFlash : function(clientId, target) {
		var _flashPanel = this.getEditor(clientId).getFlashPanel();
		_flashPanel.setVisible(!_flashPanel.isVisible());
		target.appendChild(_flashPanel.getPanel());
	},
	doInsertCode : function(clientId, target) {
		var _codePanel = this.getEditor(clientId).getCodePanel();
		_codePanel.setVisible(!_codePanel.isVisible());
		target.appendChild(_codePanel.getPanel());
	},
	swapMode : function(clientId) {
		this.getEditor(clientId).swapMode();
	},
	zoom : function(clientId) {
		this.getEditor(clientId).swapZoom();
	}
}
Q.F.UIEditor.Utils = {
	createTable : function(table, rowCount, colCount) {
		var rows = new Array();
		for ( var i = 0; i < rowCount; i++) {
			var row = new Row();
			row.obj = table.insertRow(i);
			for ( var n = 0; n < colCount; n++) {
				row.columns[n] = row.obj.insertCell(n);
			}
			rows[i] = row;
		}
		function Row() {
			this.obj = null;
			this.columns = new Array(); // 行内的所有列
		}
		return rows;
	},
	createButton : function(value) {
		var button = document.createElement("input");
		button.setAttribute("type", "button");
		button.setAttribute("value", value);
		button.style.cssText = "width:80px;height:30px;border:3px solid #F0F0F0;cursor:pointer;";
		return button;
	},
	createInput : function(width, height) {
		var input = document.createElement("input");
		input.style.cssText = "border:1px solid #C0C0C0;";
		input.setAttribute("type", "text");
		input.style.width = width + "px";
		input.style.height = height + "px";
		return input;
	},
	createCheckBox : function() {
		var id = "checkbox_" + new Date().getTime();
		var input = document.createElement("input");
		input.style.cssText = "border:1px solid #C0C0C0;";
		input.setAttribute("type", "checkbox");
		input.setAttribute("id", id);
		input.setAttribute("name", id);
		return input;
	},
	createLabel : function(des, forId) {
		var label = document.createElement("label");
		label.setAttribute("for", forId);
		label.innerHTML = des;
		return label;
	},
	createHeader : function(title) {
		var header = document.createElement("div");
		header.innerHTML = title;
		header.style.cssText = "width:98.5%;height:22px;background:#C0C0C0;font-weight:Bold;padding:3px;border:0px solid red;";
		return header;
	}
}
Q.F.UIEditor.Editor = function(ID_CLIENT, ID_MIN_ZONE,
		ID_FULL_ZONE, ID_VIEW_ZONE, ID_INPUT, ID_IFRAME, ID_CONTENT, ID_MODE, ID_TOOLS, ID_TOOLS_EXT, ID_ZOOM_IN, ID_ZOOM_OUT, 
		colorList) {
	this.clientId = ID_CLIENT;
	this.client = document.getElementById(ID_VIEW_ZONE);
	this.minZone = document.getElementById(ID_MIN_ZONE);
	this.fullZone = document.getElementById(ID_FULL_ZONE);
	this.input = document.getElementById(ID_INPUT);
	this.iframe = document.getElementById(ID_IFRAME);
	this.content = document.getElementById(ID_CONTENT);
	this.mode = document.getElementById(ID_MODE);
	this.tools = document.getElementById(ID_TOOLS);
	this.toolsExt = document.getElementById(ID_TOOLS_EXT);
	this.zoomInButton = document.getElementById(ID_ZOOM_IN);
	this.zoomOutButton = document.getElementById(ID_ZOOM_OUT);

	this.zoomIn = false; // true为全屏，false为正常
	this.doc = null;
	this.colorList = colorList;
	this.colorPanel = null; // 颜色面板
	this.linkPanel = null; // 超链接面板
	this.imagePanel = null; // 图片面板
	this.flashPanel = null; // Flash面板
	this.codePanel = null; // 代码面板

	// ---- Interface
	
	// Get Editor value
	this.getValue = function() {
		this.updateState();
		return this.input.value;
	}
	// Set Editor value
	this.setValue = function(value) {
		this.input.value = value;
		if (this.mode.value == 1)
			this.doc.body.innerHTML = value;
	}
	// Add value to the Editor
	this.addValue = function(value) {
		var temp = this.getValue();
		this.setValue(temp + value);
	}
	
	// ---- init
	
	this.init = function(_self) {
		// 打开Doc
		this.openDocument();

		// 默认非全屏状态
		this.fullZone.style.display = "none";
		this.zoomOutButton.style.display = "none";

		// 1.初始化数据，因为这有可能是经过回传之后的重新渲染，
		// input可能存在value,并且如果初始模式是normal时，则必须将input中的value设
		// 置到iframe中
		if (this.mode.value == 1) {
			this.doc.body.innerHTML = this.getHtmlData();
		}

		// 2.初始化状态模式
		this.changeMode(this.mode.value);

		// 3.创建并设置监听器
		var _fun_action = function() {
			_self.updateState();
		}
		if (this.doc.addEventListener) {
			this.doc.addEventListener("blur", _fun_action, true);
			this.doc.addEventListener("focus", _fun_action, true);
		} else if (this.doc.attachEvent) {
			this.doc.attachEvent("onkeyup", _fun_action);
			this.doc.attachEvent("onblur", _fun_action);
			this.doc.attachEvent("onfocus", _fun_action);
		}
		this.initToolsStyle();
		this.input.style.height = "100%";
		this.iframe.style.height = "100%";
		this.content.style.border = "1px solid #C0C0C0";
		this.content.height = "100%";
	}
	this.initToolsStyle = function() {
		var children = findDivs(this.tools.childNodes);
		var childrenExt = findDivs(this.toolsExt.childNodes);
		for ( var i = 0; i < children.length; i++) {
			if (i == 15 || i == 16) // 超过两个select框
				continue;
			initStyle(children[i]);
		}
		for ( var n = 0; n < childrenExt.length; n++) {
			initStyle(childrenExt[n]);
		}
		function initStyle(obj) {
			obj.onmouseover = function() {this.style.border = "1px solid #C0C0C0";}
			obj.onmouseout = function() {
				this.style.border = "1px solid #F0F0F0";
			}
		}
		function findDivs(nodes) {
			var _arr = new Array();
			for ( var i = 0; i < nodes.length; i++) {
				var _currentNode = nodes.item(i);
				if (_currentNode.id != "clear" && _currentNode.tagName != null && (_currentNode.tagName == "DIV" || _currentNode.tagName == "div")) {
					_arr.push(_currentNode);
				}
			}
			return _arr;
		}
	}
	this.openDocument = function() {
		this.doc = this.iframe.contentWindow.document;
		this.doc.designMode = "On";
		this.doc.contentEditable = true;
		this.doc.open();
		this.doc.writeln("<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Strict//EN\" \"http://www.w3.org/TR/html4/strict.dtd\"><html><body></body></html>");
		this.doc.close();
	}
	this.exec = function(command, param) { // 执行相关命令
		this.doc.execCommand(command, false, param);
		this.updateState();
	}
	this.execHTMLCode = function(htmlCode) {
		var range = this.getRange();
		if (range) {
			// 有选中区域
			if (range.text != "") {
				range.pasteHTML(htmlCode);
			} else { // 没有选中区域,避免将内容加载到parent窗口中(IE)
				this.doc.body.innerHTML += htmlCode;
			}
		} else {
			this.doc.execCommand('insertHTML', false, htmlCode);
		}
		this.updateState();
	}
	this.getRange = function() {
		var selection = this.doc.selection;
		return (selection ? selection.createRange() : null);
	}
	this.getHtmlData = function() {return this.input.value;}
	this.getNormalData = function() {return this.doc.body.innerHTML;}
	this.updateState = function() {
		if (this.mode.value == 1) {
			this.input.value = this.getNormalData();
		} else {
			this.doc.body.innerHTML = this.getHtmlData();
		}
	}
	this.swapMode = function() {
		this.changeMode(this.mode.value == 1 ? 0 : 1);
	}
	this.swapZoom = function() {
		// 保存值，在FF及部分浏览器下必须重新打开doc,并赋值,否则可能丢失值的问题
		var val = this.getValue();
		if (this.zoomIn) {
			this.zoomIn = false; // 缩小
			this.minZone.appendChild(this.client);
			this.fullZone.style.display = "none";
			this.input.style.minHeight = "200px";
			this.zoomInButton.style.display = "block";
			this.zoomOutButton.style.display = "none";
		} else {
			this.zoomIn = true; // 放大
			this.fullZone.appendChild(this.client);
			this.fullZone.style.display = "block";
			this.input.style.minHeight = "600px";
			this.zoomInButton.style.display = "none";
			this.zoomOutButton.style.display = "block";
		}
		this.openDocument();
		this.setValue(val);
	}
	// 改变编辑模式normal(1) or html(0)
	this.changeMode = function(mode) {
		this.updateState();
		if (mode == 1) {
			this.mode.value = 1;
			this.iframe.style.display = "block";
			this.tools.style.display = "block";
			this.input.style.display = "none";
		} else if (mode == 0) {
			this.mode.value = 0;
			this.input.style.display = "block";
			this.iframe.style.display = "none";
			this.tools.style.display = "none";
		}
	}
	this.getColorPanel = function() {
		if (!this.colorPanel) {
			this.colorPanel = new Q.F.UIEditor.Editor.ColorPanel(this);
		}
		this.colorPanel.setVisible(true);
		return this.colorPanel;
	}
	this.getLinkPanel = function() {
		if (!this.linkPanel) {this.linkPanel = new Q.F.UIEditor.Editor.LinkPanel(this);}
		return this.linkPanel;
	}
	this.getImagePanel = function() {
		if (!this.imagePanel) {this.imagePanel = new Q.F.UIEditor.Editor.ImagePanel(this);}
		return this.imagePanel;
	}
	this.getFlashPanel = function() {
		if (!this.flashPanel) {this.flashPanel = new Q.F.UIEditor.Editor.FlashPanel(this);}
		return this.flashPanel;
	}
	this.getCodePanel = function() {
		if (!this.codePanel) {this.codePanel = new Q.F.UIEditor.Editor.CodePanel(this);}
		return this.codePanel;
	}
	this.init(this); // 初始化
}

Q.F.UIEditor.Editor.ColorPanel = function(editor) {
	this.editor = editor; // Which Editor
	this.panel = null; // 颜料面板
	this.task = null; // ForeColor,BackColor
	this.init = function() {
		var header = Q.F.UIEditor.Utils.createHeader("选择颜色");
		this.panel = document.createElement("div");
		this.panel.style.cssText = "width:224px;border:3px solid #C0C0C0;background:#FFF;position:absolute;";
		this.panel.appendChild(header);
		var colorList = editor.colorList.split(",");
		for ( var i = 0; i < colorList.length; i++) {
			var piece = document.createElement("div");
			piece.style.cssText = "width:30px;height:30px;float:left;border:1px solid #F0F0F0;";
			piece.style.background = colorList[i];
			this.loadEvent(piece, this);
			this.panel.appendChild(piece);
		}
		var _self = this;
		header.onmouseover = function() {
			_self.setVisible(true);
		}
	}
	this.loadEvent = function(obj, colorPanel) {
		obj.onmouseover = function() {
			this.style.border = "1px solid Black";
			colorPanel.setVisible(true);
		}
		obj.onmouseout = function() {
			this.style.border = "1px solid #F0F0F0";
			colorPanel.setVisible(false);
		}
		obj.onmousedown = function() {colorPanel.editor.exec(colorPanel.task, this.style.backgroundColor);}
	}
	this.setVisible = function(bool) {
		this.panel.style.display = bool ? "block" : "none";
		this.panel.style.zIndex = Q.U.zIndex++;
	}
	this.getPanel = function() {return this.panel;}
	this.setTask = function(task) {this.task = task;} // [ForeColor,BackColor]设置前景/背景配色
	this.init(); // 初始化
}

Q.F.UIEditor.Editor.LinkPanel = function(editor) {
	this.editor = editor;
	this.panel = null;
	this.inputURL = null; // URL 地址
	this.inputDes = null; // 描述
	this.inputTarget = null; // 是否在新窗口打开
	this.submitButton = null; // 提交按钮

	this.init = function(_self) {
		this.panel = document.createElement("div");
		this.inputURL = Q.F.UIEditor.Utils.createInput(300, 20);
		this.inputDes = Q.F.UIEditor.Utils.createInput(300, 20);
		this.inputTarget = Q.F.UIEditor.Utils.createCheckBox();
		this.submitButton = Q.F.UIEditor.Utils.createButton("确定");

		var header = Q.F.UIEditor.Utils.createHeader("Insert Link");
		var table = document.createElement("table");
		var rows = Q.F.UIEditor.Utils.createTable(table, 4, 2);
		rows[0].columns[0].innerHTML = "URL";
		rows[0].columns[1].appendChild(this.inputURL);
		rows[1].columns[0].innerHTML = "描述";
		rows[1].columns[1].appendChild(this.inputDes);
		rows[2].columns[0].innerHTML = "";
		rows[2].columns[1].appendChild(this.inputTarget);
		rows[2].columns[1].appendChild(Q.F.UIEditor.Utils.createLabel("新窗口打开", this.inputTarget.id));
		rows[3].columns[0].innerHTML = "";
		rows[3].columns[1].appendChild(this.submitButton);
		this.submitButton.onclick = function() {_self.submit();}
		// zone
		this.panel.style.cssText = "width:350px;border:3px solid #C0C0C0;background:#FFF;position:absolute;";
		header.style.cursor = "move";
		table.setAttribute("border", 0);
		table.setAttribute("cellspacing", "3");
		table.setAttribute("cellpadding", "3");
		this.panel.appendChild(header);
		this.panel.appendChild(table);
		Q.U.toEnableDrag(header, this.panel);
		this.setVisible(false); // 默认为关闭的
	}
	this.setVisible = function(flag) {this.getPanel().style.display = (flag ? "block" : "none");}
	this.isVisible = function() {return (this.getPanel().style.display != "none");}
	this.submit = function() {
		this.setVisible(false);
		var target = this.inputTarget.checked ? " target=\"_blank\" " : "";
		var htmlCode = "<a href=\"" + this.inputURL.value + "\" " + target
				+ ">" + this.inputDes.value + "</a>";
		this.editor.execHTMLCode(htmlCode);
		this.inputURL.value = "";
		this.inputDes.value = "";
	}
	this.getPanel = function() {return this.panel;}
	this.init(this);
}
Q.F.UIEditor.Editor.ImagePanel = function(editor) {
	this.editor = editor;
	this.panel = null;
	this.inputSRC = null; // 图片地址
	this.inputAlt = null; // 替换文字(alt)
	this.submitButton = null; // 提交按钮

	this.init = function(_self) {
		this.panel = document.createElement("div");
		this.inputSRC = Q.F.UIEditor.Utils.createInput(300, 20);
		this.inputAlt = Q.F.UIEditor.Utils.createInput(300, 20);
		this.submitButton = Q.F.UIEditor.Utils.createButton("确定");
		var header = Q.F.UIEditor.Utils.createHeader("Insert Image");
		var table = document.createElement("table");
		var rows = Q.F.UIEditor.Utils.createTable(table, 3, 2);
		rows[0].columns[0].innerHTML = "图片URL：";
		rows[0].columns[1].appendChild(this.inputSRC);
		rows[1].columns[0].innerHTML = "替换文字";
		rows[1].columns[1].appendChild(this.inputAlt);
		rows[2].columns[0].innerHTML = "";
		rows[2].columns[1].appendChild(this.submitButton);
		this.submitButton.onclick = function() {
			_self.submit();
		}
		// zone
		this.panel.style.cssText = "width:370px;border:3px solid #C0C0C0;background:#FFF;position:absolute;";
		header.style.cursor = "move";
		table.setAttribute("border", 0);
		table.setAttribute("cellspacing", "3");
		table.setAttribute("cellpadding", "3");
		this.panel.appendChild(header);
		this.panel.appendChild(table);
		Q.U.toEnableDrag(header, this.panel);
		this.setVisible(false); // 默认为关闭的
	}
	this.setVisible = function(flag) {this.getPanel().style.display = (flag ? "block" : "none");}
	this.isVisible = function() {return (this.getPanel().style.display != "none");}
	this.submit = function() {
		this.setVisible(false);
		if (this.inputSRC.value == "") {return;}
		var htmlCode = "<img src=\"" + this.inputSRC.value + "\" alt=\""
				+ this.inputAlt.value + "\"></img>";
		this.editor.execHTMLCode(htmlCode);
		this.inputSRC.value = "";
		this.inputAlt.value = "";
	}
	this.getPanel = function() {return this.panel;}
	this.init(this);
}
Q.F.UIEditor.Editor.FlashPanel = function(editor) {
	this.editor = editor;
	this.panel = null;
	this.inputURL = null; // 图片地址
	this.inputWidth = null;
	this.inputHeight = null;
	this.submitButton = null; // 提交按钮

	this.init = function(_self) {
		this.panel = document.createElement("div");
		this.inputURL = Q.F.UIEditor.Utils.createInput(300, 20);
		this.inputWidth = Q.F.UIEditor.Utils.createInput(50, 20);
		this.inputHeight = Q.F.UIEditor.Utils.createInput(50, 20);
		this.submitButton = Q.F.UIEditor.Utils.createButton("确定");
		var header = Q.F.UIEditor.Utils.createHeader("Insert Flash");
		var table = document.createElement("table");
		var rows = Q.F.UIEditor.Utils.createTable(table, 4, 2);
		rows[0].columns[0].innerHTML = "Flash URL：";
		rows[0].columns[1].appendChild(this.inputURL);

		rows[1].columns[0].innerHTML = "宽度";
		rows[1].columns[1].appendChild(this.inputWidth);

		rows[2].columns[0].innerHTML = "高度";
		rows[2].columns[1].appendChild(this.inputHeight);

		rows[3].columns[0].innerHTML = "";
		rows[3].columns[1].appendChild(this.submitButton);
		this.submitButton.onclick = function() {
			_self.submit();
		}
		this.inputWidth.value = "400";
		this.inputHeight.value = "400";

		// zone
		this.panel.style.cssText = "width:370px;border:3px solid #C0C0C0;background:#FFF;position:absolute;";
		header.style.cursor = "move";
		table.setAttribute("border", 0);
		table.setAttribute("cellspacing", "3");
		table.setAttribute("cellpadding", "3");
		this.panel.appendChild(header);
		this.panel.appendChild(table);
		Q.U.toEnableDrag(header, this.panel);
		this.setVisible(false); // 默认为关闭的
	}
	this.setVisible = function(flag) {this.getPanel().style.display = (flag ? "block" : "none");}
	this.isVisible = function() {return (this.getPanel().style.display != "none");}
	this.submit = function() {
		this.setVisible(false);
		if (this.inputURL.value == "")
			return;
		var htmlCode = "<object width=\"@width\" height=\"@height\">";
		htmlCode += "<param name=\"movie\" value=\"@url\" />";
		htmlCode += "<param name=\"quality\" value=\"high\" />";
		htmlCode += "<embed src=\"@url\" type=\"application/x-shockwave-flash\" width=\"@width\" height=\"@height\" wmode=\"opaque\"></embed>";
		htmlCode += "</object>";
		htmlCode = htmlCode.replaceAll("@url", this.inputURL.value);
		htmlCode = htmlCode.replaceAll("@width", this.inputWidth.value);
		htmlCode = htmlCode.replaceAll("@height", this.inputHeight.value);
		this.editor.execHTMLCode(htmlCode);
		this.inputURL.value = ""
	}
	this.getPanel = function() {return this.panel;}
	this.init(this);
}
